home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / System / ControlPanelLock / INIT.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-03  |  1.2 KB  |  82 lines  |  [TEXT/KAHL]

  1. #include <Traps.h>
  2. #include <SetUpA4.h>
  3. #include "CPanel Lock.h"
  4.  
  5.  
  6. int strcmp(char *s1, char *s2)
  7. {
  8.     while(*s1 == *s2 && *s2 && *s1)
  9.     {
  10.         s1++; 
  11.         s2++;
  12.     }
  13.     
  14.     if (*s1 == *s2) 
  15.         return(EQSTR);
  16.     else
  17.         return(!EQSTR);
  18. }
  19.  
  20.  
  21.  
  22. void ShowInit(int ID)
  23. {
  24. Handle        procH;
  25.         
  26.     if ((procH = GetResource('PROC', ShowIconID)) != 0L)
  27.     {
  28.         HLock(procH);
  29.         CallPascal(ID, -1, *procH);
  30.         HUnlock(procH);
  31.         ReleaseResource(procH);
  32.     }
  33. }
  34.  
  35.  
  36.  
  37. main()
  38. {
  39. char         *moof,installed;
  40. Handle         myCodeRes;
  41. long        theSize;
  42.  
  43.     RememberA0();
  44.     SetUpA4();
  45.     
  46.     installed = FALSE;
  47.     
  48.     myCodeRes = GetNamedResource('RoyW',patchName);
  49.  
  50.     if(myCodeRes != nil)
  51.     {
  52.         theSize = GetHandleSize(myCodeRes);
  53.         for(moof=*myCodeRes;theSize>0 && strcmp(moof,"Moof")!=EQSTR;moof++,theSize--);
  54.         
  55.         if (theSize>0L && strcmp(moof,"Moof")==EQSTR)
  56.         {
  57.             moof += 4L;
  58.             
  59.             *((long *) moof) = NGetTrapAddress((_OpenDeskAcc - 0xA000),ToolTrap);
  60.             
  61.             DetachResource(myCodeRes);
  62.             HUnlock(myCodeRes);
  63.             MoveHHi(myCodeRes);
  64.             HLock(myCodeRes);
  65.             
  66.             NSetTrapAddress((long) StripAddress(*myCodeRes),(_OpenDeskAcc - 0xA000),ToolTrap);
  67.                 
  68.             installed = TRUE;
  69.         }
  70.     }
  71.     
  72.     if (!installed)
  73.     {
  74.         ShowInit(badICON);
  75.         SysBeep(1);
  76.     }
  77.     
  78.     else
  79.         ShowInit(goodICON);
  80.     
  81.     RestoreA4();
  82. }